#include "ourhdr.h"

#define SNAKE_HEAD	'#'
#define SNAKE_BODY	'*'
#define FOOD		'$'

Snake::Snake()
	: Object(), m_direction(Direction::LEFT)
{
	Pixel first(Pixel::max_row/2, Pixel::max_col/2,SNAKE_HEAD); 
	addBack(first);
}

Pixel Snake::head() const{
	return this->first();
}

void Snake::move(const Pos &next, Direction direction){
	m_direction = direction;
	(*this)[0].setCharacter(SNAKE_BODY);
	this->delBack();
	this->addFront(Pixel(next,SNAKE_HEAD));
}

void Snake::eat(const Pixel &pixel, Direction direction){
	this->addFront(pixel);
	m_direction = direction;
}

void Snake::eat(const Pos &pos, Direction direction){
	(*this)[0].setCharacter(SNAKE_BODY);
	this->addFront(Pixel(pos, SNAKE_HEAD));
}
